package whf.framework.web.tag;

import java.util.List;

import javax.servlet.jsp.JspException;

import whf.framework.util.Pair;
import whf.framework.util.StringUtils;
import whf.framework.util.Utils;

/**
 * 分页Tag
 * @author wanghaifeng
 *
 */
public class TabTag extends HtmlTag{
	private List<Pair<String, String>> links = Utils.newArrayList();
	
	/**
	 * @param links 分组连接
	 */
	public void setLinks(List<Pair<String, String>> links){
		this.links = links;
	}
	
	/**
	 * @param links 连接字符串
	 */
	public void setLinkString(String links){
		String[] tmps = StringUtils.split(links, ";");
		for(int i=0; tmps != null && i < tmps.length; i++){
			String tmp = tmps[i];
			if(tmp == null) continue;
			String[] x = StringUtils.split(tmp, ":");
			if(x == null || x.length !=2) continue;
			this.links.add(new Pair<String, String>(x[0], x[1]));
		}
	}
	
	public int doStartTag() throws JspException{
		return 2;
	}
	
	public int doEndTag() throws JspException{
		
		return EVAL_PAGE;
	}
}
